<include file="../header" />
<link rel="stylesheet" href="/assets/schoolirs/css/default.css"/>
<body>
<div class="wraper">
    <div class="load">
        <img class="load-bee" src="/assets/schoolirs/images/load-bee.png"/>
    </div>
    <div class="top">
		<p>
			<a href="/base/center/center/account_id/{BEESCRM:$account_id}" class="iconfont icon-zuo pull-left"></a>
			<span class="iconfont icon-dingcanguanli"></span>{BEESCRM:$title}
		</p>
    </div>
	<!--餐厅档口信息 开始-->
	<volist name="data" id="vo">
		<div class="lists tb-mode">
			<a href="javascript:void(0)" class="tb-cell list-left">
				<div class="img-box"><img src="{BEESCRM:$vo.window_img}"><!--<span class="rest">已售罄</span>--></div>
			</a>
			<div href="javascript:void(0)" class="tb-cell list-center">
				<p class="text-16">{BEESCRM:$vo.window_name}<!--(当日须提前{BEESCRM:$vo.advance_time}分钟预定)--></p>
				<p class="star-box">
					<span class="stars">
						<for start="0" end="$vo.composite_score"><span class="iconfont icon-xingxing star"></span></for>
						<for start="0" end="$vo.gray_star"><span class="iconfont icon-xingxing star grey-star"></span></for>
						<!-- 此处用的是综合得分 -->
						<span>{BEESCRM:$vo.composite_score}分</span>
					</span>
				</p>
				<p class="text-12 text-deepgray">{BEESCRM:$vo.refectory_name} | 提前{BEESCRM:$vo.schedule_time}分钟预订  <if condition="$vo.is_take neq ''">| {BEESCRM:$vo.is_take}</if></p>
			</div>
			<input type="hidden" value="{BEESCRM:$Eat}" id="eatTime">
			<input class="restaurant_" value="" data-id="{BEESCRM:$vo.refectory_id}" data-window="{BEESCRM:$vo.window_id}" data-time="{BEESCRM:$vo.schedule_time}"/>
		</div>
	</volist>
	<!--餐厅档口信息 结束  -->
	<div class="fenye" style="text-align: center;margin-bottom: 49px">{BEESCRM:$page}</div>
    <div class="btn-box">
        <a href="#" class="btn actived"><span class="iconfont icon-weiwaimai"></span> 预订餐</a>
        <a href="/Schoolirs/Order/myorder/res_id/{BEESCRM:$res_id}" class="btn"><span class="iconfont icon-dingdan"></span> 我的订单</a>

    </div>

	<input id="res_id" value="{BEESCRM:$res_id}" hidden/>
</div>

<include file="../commonJS" />
<script src="/assets/public/mobiscroll/mobiscroll.custom-3.0.0-beta2.min.js"></script>
<!--微信自带的返回-->
<script>

	$(function(){
		pushHistory();
		window.addEventListener("popstate", function(e) {
			//alert("我监听到了浏览器的返回按钮事件啦");//根据自己的需求实现自己的功能
			pushHistory();
		}, false);
		function pushHistory() {
			var state = {
				title: "title",
				url: "#"
			};
			window.history.pushState(state, "title", "#");//禁用
		}

	});
</script>
<script>
	$(function(){
		for(var i=0;i<$('.restaurant_').length;i++){
			var d = new Date();
			var time = $('.restaurant_').eq(i).data('time') + 1;
			var now = d.getHours()+':'+d.getMinutes();
			d.setMinutes(d.getMinutes()+time);
			var limitetime = d.getHours()+':'+d.getMinutes();

			var instance = mobiscroll.time($('.restaurant_').eq(i), {
				onBeforeShow: function (event, inst) {

					refectory_id = $(this).data('id');
					window_id = $(this).data('window');

					if(eatTime == 1){
						location.href = '/Schoolirs/BookDinner/menu/refectory_id/'+refectory_id+'/window_id/'+window_id+'/res_id/'+res_id;
					}
				},
				theme: 'android-holo-light',
				lang: 'zh',
				display: 'center',
				headerText: false,
				maxWidth: 60,
				defaultValue: d,
				setText: '确认就餐时间',
				min: d,
				invalid: [
					{ start: now, end: limitetime }
				]
			});
		}

		var refectory_id = '';
		var window_id = '';
		var res_id = $('#res_id').val();
		var eatTime = $("#eatTime").val();


		$('.restaurant_').change(function(){
			var eat = $(this).val();
			var info = {};
			var json = {};
			info.eat = eat;
			info.refectory_id = refectory_id;
			info.window_id = window_id;

			$.ajax({
				'url': "/Schoolirs/BookDinner/setEatTime?res_id="+res_id,
				'data': info,
				'dataType':'json',
				'type': 'POST',
				'async': false,
				success: function(data) {
					if (data.status == 'S') {

						location.href = data.uri;
					}else{
						fm.alert(data.message);
						return false;
					}
				}
			});
		});

	})
</script>
</body>
</html>
